package com.heima.admin.controller.v1;

import com.heima.admin.service.ManualAuditService;
import com.heima.model.admin.dtos.NewsAuthDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class ManualAuditController {
    @Autowired
    private ManualAuditService manualAuditService;

    /**
     * 查询文章列表
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult listQuery(@RequestBody NewsAuthDto dto){
        return manualAuditService.listQuery(dto);
    }

    /**
     * 查询文章详情
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult detailsQuery(@PathVariable("id") Integer id){

        return manualAuditService.detailsQuery(id);
    }

    /**
     * 审核失败
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult fail(@RequestBody NewsAuthDto dto){
        return manualAuditService.changeStatus(dto);
    }

    /**
     * 审核成功
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto) {
        return manualAuditService.changeStatus(dto);
    }
}
